$(document).ready(function() {    
    
    $(".sub-cat-portafolio").live("click",function(){
		var category = $(this).attr("rel");
		$.ajax({
				type: "POST",
				url: 'http://'+location.host+'/wp-content/themes/newnoise/ajax-portafolio.php',
				async: false,
				data: "category="+category+"&tipo=subcategoria",
				success: function(msg){

					$("#portafolio-items").html(msg);

				}
		});
	});
	
    $(".nivel1").live("click",function(){
		showL();
        var category = $(this).attr("rel");
		
		if(category == "servicios"){
			$.ajax({
						type: "POST",
						url: 'http://'+location.host+'/wp-content/themes/newnoise/ajax-portafolio-submenu.php',
						async: false,
						data: "category="+category,
						success: function(msg){
							//$("#content-load").hide();
							hideL();
							$('.content-submenu').html(msg);
							//$(".content-submenu").html(msg);

						}
				});
		}else{
		
			$.ajax({
						type: "POST",
						url: 'http://'+location.host+'/wp-content/themes/newnoise/ajax-portafolio.php',
						async: false,
						data: "category="+category+"&tipo=categoria",
						success: function(msg){
                                                    
							$("#portafolio-items").html(msg);

						}
				});

			$.ajax({
						type: "POST",
						url: 'http://'+location.host+'/wp-content/themes/newnoise/ajax-portafolio-submenu.php',
						async: false,
						data: "category="+category,
						success: function(msg){
							//$("#content-load").hide();
							hideL();
							$('.content-submenu').html(msg);
							//$(".content-submenu").html(msg);

						}
				}); 
		}
    });
	
    $("#menu-menu-left").addClass("nav");  
    $("#menu-menu-right").addClass("nav"); 
	$(".menu-menu-left-container").addClass("nav-collapse collapse");
	$(".menu-menu-right-container").addClass("nav-collapse collapse");
	
	$(".wpcf7-submit").addClass("btn btn-large btn-primary");
	
	
	$("#content-cliente").live("mouseover",function(){
		$("#text-servicio").stop().fadeOut(300, function () {
			$("#text-plataforma").stop().fadeOut(300, function () {
				$("#text-cliente").stop().fadeIn(300);
			});
			
		});
	});
	$("#content-servicio").live("mouseover",function(){
		$("#text-cliente").stop().fadeOut(300, function () {
			$("#text-plataforma").stop().fadeOut(300, function () {
				$("#text-servicio").stop().fadeIn(300);
			});
		});
	});
	$("#content-platafortma").live("mouseover",function(){
		$("#text-cliente").stop().fadeOut(300, function () {
			$("#text-servicio").stop().fadeOut(300, function () {
				$("#text-plataforma").stop().fadeIn(300);
			});
		});
	});
    /*$("#link-fb").live("click",function(){
        $('.anyClass').jCarouselLite = null;
        $('.prev').unbind('click');
        $('.next').unbind('click');
        
        $("#content-slide-foot").slideToggle(1000,function(){	
			
			miCarrusel();
            $("#slider-foot .jCarouselLite").jCarouselLite({
                    btnNext: ".next",
                    btnPrev: ".prev",
                    visible: 2
            });
        });
    });*/
	
	
    
});

var indice = 0;
function miCarrusel(){
	
	var li_twt = $(".galeria-twt ul li").size();	
	
	
	/*alert("ind antes de entrar "+indice); 
	alert("li  "+li_twt); */
	if(indice < li_twt){
		if(indice == 0){
			indice = indice + 1;
			//alert("ind "+indice);			
			setInterval(function(){miCarrusel()},15000);
		}else{
			//alert("ind else "+indice);
			var margin = $(".galeria-twt ul li:first-child").css("margin-top");
			//alert("margin1 else  "+margin);
			margin = margin.replace(/px/g,"");
			margin = parseInt(margin) + 70;

			//alert("margin2 else  "+margin);
			$(".galeria-twt ul li:first-child").css("margin-top","-"+margin+"px");
			indice = indice + 1;
			setInterval(function(){miCarrusel()},15000);
		}
		
	}else{
		
		$(".galeria-twt ul li:first-child").css("margin-top","2px");
		indice = 0;
		//alert("indice > li_twt "+indice);
		setInterval(function(){miCarrusel()},15000);
	}
	
}
function showL() {
	
	$("#content-load-cat-port").show();
}
function hideL() {
	$("#content-load-cat-port").hide();
}
